<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta name="apple-itunes-app" content="app-id=468944728">

<meta id="viewport" name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no">

<title>授权页</title>

<head>

<script type="text/javascript" src="js/jquery.min.js"></script>

<script>



var appid = '';

var secret = '';

var weixinId = 1;

var param = getUrlParam("param");
var strs = new Array(); //定义一数组 
strs = param.split("-"); //字符分割 
var type = strs[0];
var memberId = strs[1]; //
var refId = strs[2];
var limitId = strs[3];



var url_ = 'http://weixin.zjpxny.com/authorizationPage.html?param='+param;

var redirect_uri = encodeURI(url_);

var code = '';


	//appid = jQuery.trim(data.appId);
    appid = 'wx5a7259af417cf2e9';

	//secret = jQuery.trim(data.appSecret);
    secret = '04c36859319b12a1643bf3e5533a8572';

	code = getUrlParam("code");
	if(code==null){
		window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+"&redirect_uri="+redirect_uri+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
	}else{
		
		//alert('appid:'+appid+',secret:'+secret+',code:'+code+',grant_type:authorization_code');
		//获取当前微信用户信息
        /**
		$.ajax({

			type:'post',

			dataType:'json',

			url:'http://mobile.haowukongtou.com/weixin/getWxUserInfo',

			data:{'type':type,'recId':memberId,'appid':appid,'secret':secret,'code':code,'grant_type':'authorization_code'},

			async:false,

			success:function(data){

				var result = JSON.parse(data.result);

				if(result.errcode == 48001){

					window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+"&redirect_uri="+redirect_uri+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";

				}else{

	          		if(result.openid == undefined || result.openid == 'undefined'){

	          			window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+"&redirect_uri="+redirect_uri+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";

	          		}else{

	          			//alert("shopId="+shopId+",externalNo="+result.openid+",externalName="+result.nickname+",logo="+result.headimgurl+',shopId='+shopId);

	          			$.ajax({

		          			type:'post',

		          			dataType:'json',

		          			url:"http://mobile.haowukongtou.com/weixin/getMemberByOpenId",

		          			data:{'openId':result.unionid,'userId':memberId},

		          			async:false,

		          			success:function(data){

		          				if(data!=null){
									if(type == 6  && (data.mobile == '' || data.mobile == null)) {
										window.location.href = 'http://weixin.haowukongtou.com/bind.html?memberId='+data.id+'&type='+type+'&productId='+refId+'&limitId='+limitId;
									} else {
										if(type == 1) { //开店礼包
											window.location.href = 'http://weixin.haowukongtou.com/open.html?memberId='+data.id;
										} else if(type == 2) { //店铺精选
											window.location.href = 'http://weixin.haowukongtou.com/house.html?memberId='+data.id;
										} else if(type == 3){ //商品详情-普通
											window.location.href = 'http://weixin.haowukongtou.com/proDetail.html?type=1&id='+refId+'&limitId=&memberId='+data.id;
										} else if(type == 4){ //商品详情-限时购
											window.location.href = 'http://weixin.haowukongtou.com/proDetails-xs.html?type=2&id='+refId+'&limitId='+limitId+'&memberId='+data.id;
										} else if(type == 5){ //邀请会员
											window.location.href = 'http://weixin.haowukongtou.com/yaoqing.html?memberId='+data.id;
										} else if(type == 6){ //分享红包
											window.location.href = 'http://weixin.haowukongtou.com/share/share-yb1.html?memberId='+data.id+'&shareId='+refId;
										} else if(type == 7){ //分享品牌
                                            window.location.href = 'http://weixin.haowukongtou.com/brandDetail.html?brandId='+refId+'&imgUrl='+limitId+'&memberId='+data.id;
                                        }
									}
									
						        }else{

						          	alert('会员不存在!');

						        }

		          				

		          			},

		          			error:function(){

					           alert('会员不存在2!');

					         }

		          		});

	          		}

	          		

	          	}

          		

			},

			error:function(){

				alert('系统异常3');

			}

			

		})
         *
         */
	}






//地址栏获取参数

function getUrlParam(name){

	var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 

	var r = window.location.search.substr(1).match(reg);  

	if (r!=null) 

		return unescape(r[2]); 

	return null; 

} 

</script>

</head>

<body></body>

</html>